(function(window) {
    var appCtrl = {
        bindEven: function() {
            var bindings = [{
                    element: 'body',
                    event: hiApp.device.click,
                    handler: this.body_click
                }
            ];
            bindEvents(bindings);
        },
        

        init: function(page) {
            $(".pages").height($(window).height());
            appCtrl.bindEven();
           // this.showToolbar();
           // appCtrl.setToolbar(page);
           // appCtrl.hideToolbar(page);
            

        },
        afterShow:function(page){
          //console.log(page);
          //alert(1);
          //appCtrl.setToolbar(page);
         // appCtrl.hideToolbar(page);
        },
        //当前选中菜单
        setToolbar: function(page) {
            if (typeof(page) != "object") page = {};
            var s = "";
            var a = "";
            var i = 0;
            var name = "";
            var page_name = page.name;
            $.each(page.query, function(k, v) {
                if (i == 0) {
                    s = k;
                    a = v;
                }
                i++;
            })
            switch (s) {
                case 'Index':
                    name = "Index";
                    break;
                case 'User':
                    name = "User";
                    break;
                case 'Subject':
                    name = "Home";
                    break;
            }

            switch (page_name) {
                case 'Index_index':
                    name = "Index";
                    break;

                case 'Index_my_subject':
                    name = "Home";
                    break;
                case 'Subject_index':
                    name = "Home";
                    break; 
                case 'User_index':
                    name = "User";
                    break;        
            }
            //alert(page_name);
           
            $(".toolbar .toolbar-inner a").removeClass("active");
            $(".toolbar .toolbar-inner").find("[name='" + name + "']").addClass("active");

        },

        hideToolbar:function(page){
           if (hiApp.device.pc) {
            $(".toolbar").hide();
            return;
           }
           var page_name = page.name;
           if(page_name=="Index_subjectList" ){
              $(".toolbar").hide();
           }else{
              $(".toolbar").show();
           }

          
        },
       
    };

    window.YzPay_appCtrl = appCtrl;

})(window);
